/*
 * DialogScrollView.java
 * business
 *
 * Created by ChenTao on 2017/2/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.widget.view;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

import com.yidiandao.business.utils.SysUtils;

/**
 * 用于对话框中的ScrollView.最大高度为屏幕高度的一般
 *
 * <p>Created by ChenTao(chentao7v@gmail.com) on 2017/2/17 15:20
 */
public class DialogScrollView extends ScrollView {
    public DialogScrollView(Context context) {
        super(context);
    }

    public DialogScrollView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

        // 屏幕的高度
        int screenHeight = SysUtils.getScreenHeight(getContext());
        int scrollViewHeight = screenHeight / 2;

        int halfScreenHeightMeasureSpec =
                MeasureSpec.makeMeasureSpec(scrollViewHeight, MeasureSpec.AT_MOST);

        super.onMeasure(widthMeasureSpec, halfScreenHeightMeasureSpec);
    }
}
